package main

import (
	"fmt"
	"math/rand"
	"sync"
	"time"
)

type Person struct {
	Name string
}
type House struct {
	sync.Mutex
}

var wg sync.WaitGroup

func main() {
	wg.Add(10)
	house := House{}
	for i := 0; i < 10; i++ {
		go func(wg *sync.WaitGroup, house *House) {
			defer wg.Done()

			house.Lock()
			n := rand.Intn(5)
			fmt.Printf("sleep %d s\n", n)
			time.Sleep(time.Duration(n) * time.Second)
			house.Unlock()
		}(&wg, &house)
	}

	wg.Wait()
	fmt.Println("main....")
}
